<template>
  <div>
    <el-radio-group v-model="select1" @input="selectChannel">
      <el-radio-button label="0">热门</el-radio-button>
      <el-radio-button v-for="(item, index) in channelList" :key="item.id" :label="item.id">{{ item.name }}
      </el-radio-button>
    </el-radio-group>
    <div v-for="(item, index) in hotVideoList" style="margin-top: 5px " @click="$router.push(`/video/${item.id}`)">
      <img :src="item.videoCover" style="width: 300px; height: 168px">
      <div style="font-size: 15px"> {{ item.videoName }} </div>
      <br>
      <div style="font-size: 13px"> {{ item.videoAuthor }} - {{ item.videoDate }} - {{ item.score }} </div>
    </div>
  </div>
</template>

<script>
import { hotVideo, listVideo } from '@/api/video'
import { listChannel } from '@/api/channel'
export default {
  data () {
    return {
      hotVideoList: null,
      queryParams: {
        channelId: 0
      },
      channelList: null,
      select1: 0
    }
  },
  async created () {
    // 获取频道列表
    const res = await listChannel()
    this.channelList = res.data.rows

    const res1 = await hotVideo(this.queryParams)
    this.hotVideoList = res1.data.data
  },
  methods: {
    async selectChannel (id) {
      this.queryParams.channelId = id

      const res = await hotVideo(this.queryParams)

      this.hotVideoList = res.data.data
    }
  }
}
</script>

<style scoped lang="less">

</style>
